package com.vipboot.auth.strategy;

import com.vipboot.auth.domain.vo.AuthTokenVo;
import com.vipboot.framework.biz.api.auth.domain.vo.ApiClientVo;
import com.vipboot.framework.core.exception.UserException;
import com.vipboot.framework.core.spring.SpringContextUtil;

public interface AuthStrategy {

    String BASE_NAME = "AuthStrategy";

    /**
     * 登录
     */
    static AuthTokenVo login(String body, ApiClientVo client, String grantType) {
        // 授权类型和客户端id
        String beanName = grantType + BASE_NAME;
        if (!SpringContextUtil.containsBean(beanName)) {
            throw new UserException("授权类型不正确!");
        }
        AuthStrategy instance = SpringContextUtil.getBean(beanName);
        return instance.login(body, client);
    }

    /**
     * 登录
     */
    AuthTokenVo login(String body, ApiClientVo client);

}
